package com.xiaoqi.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaoqi.dao.PermissionDao;
import com.xiaoqi.pojo.PageResult;
import com.xiaoqi.pojo.Permission;
import com.xiaoqi.pojo.QueryPageBean;
import com.xiaoqi.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author PC
 * creationTime: 2022/11/6 16:28
 */

@Service(interfaceClass = PermissionService.class)
@Transactional
public class PermissionServiceimpl implements PermissionService {

    @Autowired
    private PermissionDao permissionDao;

    /**
     * 查询所有权限
     * @return
     */
    @Override
    public PageResult findAll(QueryPageBean queryPageBean) {
        //开启分页插叙
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        //开启分页后的第一条查询语句会被分页
        List<Permission> list = permissionDao.findAll(queryPageBean.getQueryString());
        //获取更多分页信息
        PageInfo<Permission> pageInfo = new PageInfo<>(list);

        return new PageResult(pageInfo.getTotal(),pageInfo.getList()) ;
    }

}
